//###############
//FILE : DirCommand.java
//WRITER : Daniel Lowengrub, daniel_i_l, 320687098
//EXERCISE : oop ex3 2011
//DESCRIPTION:
//See below
//###############
package oop.ex3.filemanager;

import java.util.ArrayList;

/**
 * Implements the DIR command.
 * @author daniel
 */
public class DirCommand extends UserCommand{
    private static final String DIR_COMMAND = "DIR";
    private FileDatabase _fileDatabase;

    /**
     * Construct a dir command.
     * @param connection The connection this command uses to talk to a NS.
     */
    public DirCommand(FileDatabase fileDatabase) {
        super(DIR_COMMAND);
        _fileDatabase = fileDatabase;
    }


    @Override
    public boolean executeCommand(String command) {
        ArrayList<String> files = _fileDatabase.getSortedFileNames();
        
        for (String fileName : files)
            System.out.println(fileName);
        return true;
    }

}
